Create a new Windows Form Project named LabelControls in your C# projects folder.
Change the Form1 Text to "Exploring Label Controls".
Add a label to the form.
Set the label properties:
- Name: feedbackLabel
- Text: Is programming in C# fun?
- Font: Lucida Handwriting, Italics, 10
- BorderStyle: FixedSingle
- AutoSize:True (means label is same size as text), False means otherwise
- Here is a snapshot of the design:
Add another label
Use the following properties:
- Name: answerLabel
- Text: None
- AutoSize: False
- BorderStyle: Fixed3D
- TextAlign:MiddleCenter
- Here is again another snapshot of the design:
Let's add more buttons with codes
Add 2 buttons as shown below using your own properties:
Display output in label controls
- You will add functionality (code) to each button so text will be displayed in the answerLabel
- To display output in a label control you use the following code:
- answerLabel.Text = "Exact text of the answer"
- Add code to the Yes button: Double-click the Yes button
- Add the code: answerLabel.Text = "It's lots of fun!"
- Add code to the No button: answerLabel.Text = "Are you kidding???"
- Both codes are as illustrated here:
- then "Save All"
For more details, please contact me here.
Date of last modification: March 17, 2019